<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<%@ page import="model.QnaBoard"%>
<%@ page import="board.QnaForm" %>
<%@ page import="java.util.*,util.*" %>
<%@ include file="../common/include/header.jsp" %>



<div style="width:980px"> 
	<table style="border: 0" cellpadding="0" cellspacing="0" border="0">
		<%-- 왼쪽 메뉴--%>
			<tr>
				<td style="vertical-align: top;width: 180px;background-color:  #fdb73a;">
					<%@ include file="/common/include/leftmenu.jsp" %>
				</td>
				
		<%-- 오른쪽 게시판 detail--%>	
				<td style="text-align: center;width: 800px;vertical-align: top;">
					<div style="background-color: #ffffff;text-align: center;">
						<html:form action="qnaboard.do">
							<%@include file="logo.jsp" %>	
							<div class="boardname">질문&답변게시판</div>		
							<table style="width:700px;text-align: center;">
								<tr>
									<td style="font-weight:bold; center;padding: 10px">∴<bean:write name="qnaForm" property="qbtitle"/></td>
								</tr>
								<tr>
									<td style="text-align: right;padding: 10px"></td>					
								</tr>
								<tr>
									<td style="border: 1px dotted #bbbbbb;">
										<div style="text-align:right;">
											<span style="font-size:8pt;">[<bean:write name="qnaForm" property="rownum"/>]</span>&nbsp;
											<span><a href="javascript:;" onmousedown="popmenu1('<bean:write name="qnaForm" property="mid"/>')" style="color:#2f4f4f;">
											<bean:write name="qnaForm" property="mid"/></a></span>&nbsp;
											<span style="font-size:7pt;color: #aaaaaa;"><bean:write name="qnaForm" property="qbdate"/></span>&nbsp;
										</div>
										<div id="contents" style="background: #ffffff;text-align: left;padding: 10px;"><bean:write name="qnaForm" property="qbcontent"/>
										</div>												
										</td>
								</tr>			
								
							<%-- next,preview --%>		
							<%QnaForm qnaForm = (QnaForm)request.getAttribute("qnaForm"); %>
							<logic:notEqual value="<%=qnaForm.getQbno() %>" name="qnaForm" property="qbrefno">
							
							</logic:notEqual>
							<logic:equal value="<%=qnaForm.getQbno() %>" name="qnaForm" property="qbrefno">
								<logic:notEmpty name="qnaForm" property="preview">
								<tr>
									<td colspan="2" style="text-align: left;padding: 10px">
										이전글&nbsp;:&nbsp;
										<a href="qnaboard.do?method=detailview&qbno=<bean:write name="qnaForm" property="preview.qbno"/>">
										<bean:write name="qnaForm" property="preview.qbtitle"/></a>							
									</td>
								</tr>
								</logic:notEmpty>
								<logic:notEmpty name="qnaForm" property="next">
								<tr>
									<td colspan="2" style="text-align: left;padding: 10px">
										다음글&nbsp;:&nbsp;
										<a href="qnaboard.do?method=detailview&qbno=<bean:write name="qnaForm" property="next.qbno"/>">
										<bean:write name="qnaForm" property="next.qbtitle"/></a>							
									</td>
								</tr>
								</logic:notEmpty>
							</logic:equal>
							
							<%-- 답글 부분 --%>			
																
							<tr>
								<td colspan="2" style="text-align: right;">
									<logic:equal value="<%=qnaForm.getQbno() %>" name="qnaForm" property="qbrefno">
										<html:link href="javascript:doAction('insertForm');"><img src="<%=imagePath %>icon_reply.jpg"/></html:link>
									</logic:equal>
									
									<logic:equal value="<%=user.getMid() %>" name="qnaForm" property="mid">					
										<html:link href="javascript:doAction('updateForm')"><img src="<%=imagePath %>icon_update.jpg"/></html:link>
										<html:link href="javascript:doAction('delete');"><img src="<%=imagePath %>icon_delete.jpg"/></html:link>	
									</logic:equal>
									
									<logic:notEqual value="<%=user.getMid() %>" name="qnaForm" property="mid">
										<logic:greaterEqual value="7" name="user" property="userInfo.lvno" scope="session">
											<html:link href="javascript:doAction('updateForm')"><img src="<%=imagePath %>icon_update.jpg"/></html:link>
											<html:link href="javascript:deleteConfirm();"><img src="<%=imagePath %>icon_delete.jpg"/></html:link>
										</logic:greaterEqual>
									</logic:notEqual>
					
									<html:link href="javascript:doAction('list');"><img src="<%=imagePath %>icon_list.jpg"/></html:link>
								</td>
							</tr>
						</table>			
						<input type="hidden" name="method" value=""/>
						<input type="hidden" name ="qbno" value = "<bean:write name="qnaForm" property="qbno"/>"/>
						<input type="hidden" name ="qbrefno" value = "<bean:write name="qnaForm" property="qbno"/>"/>
						<input type="hidden" name ="qbtitle" value = "<bean:write name="qnaForm" property="qbtitle"/>"/>
						<input type="hidden" name ="qbdate" value = "<bean:write name="qnaForm" property="qbdate"/>"/>
						<input type="hidden" name ="mid" value = "<bean:write name="qnaForm" property="mid"/>"/>
						<input type="hidden" name ="qbcontent" value = "<bean:write name="qnaForm" property="qbcontent"/>"/>
						<input type="hidden" name ="qbcounter" value = "<bean:write name="qnaForm" property="qbcounter"/>"/>		
						<input type="hidden" name ="currentPage" value = "<bean:write name="pager" property="currentPage"/>"/>		
						</html:form>
					</div>		
				</td>
			</tr>
		</table>
	</div>					
<%@ include file="../common/include/footer.jsp"%>

<script type="text/javascript">

	//엑션 메소드
	function doAction(m){	
		var method = document.getElementById('method');
		method.value= m;
		if(method.value==""){
			alert("null");
		}

		qnaForm.submit();
		
	}

	// fck 태그부분 처리
	window.attachEvent("onload",convert);
	function convert(){
		var content = document.getElementById('contents').innerHTML;
		
		content = content.replace(/&lt;/g,"<");
		content = content.replace(/&gt;/g,">");
		content = content.replace(/&amp;/g,"&");
		content = content.replace(/&nbsp;/g," ");
		content = content.replace(/&quot;/g,"\"");
		
		document.getElementById('contents').innerHTML = content;
	}
	function deleteConfirm(){
		var sure = window.confirm('삭제하겠습니까?');
		if(sure==true) doAction('delete');
	}
</script>